<!DOCTYPE html>
<html lang="en" xmlns:th="https://www.thymeleaf.org" xmlns:background="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8" >
    <div th:replace="common/common::html"></div>
    <title>Title</title>
    <script th:inline="javascript">
        var _gridWidth;
        var _gridHeight;

        //页面自适应
        function resizePageSize() {
            _gridWidth = $(document).width() - 12;/*  -189 是去掉左侧 菜单的宽度，   -12 是防止浏览器缩小页面 出现滚动条 恢复页面时  折行的问题 */
            _gridHeight = $(document).height() - 32 - 60; /* -32 顶部主菜单高度，   -90 查询条件高度*/
        }

        var allocateSetting = {
            check: {
                enable: true
            },
            data: {
                simpleData: {
                    enable: true
                }
            }
        };

        $(function () {
            resizePageSize();
            // allocateZtree();
            $("#addButton").click(function (event) {
                event.stopPropagation();
                var organBianMa=$("#organBianMa").val();
                var organName=$("#organName").val();
                var organType=$("#organType").val();
                var organBeiZhu=$("#organBeiZhu").val();
                $.ajax({
                        type: 'post',
                        async: false,
                        dataType : 'json',
                        url: /*[[@{addOrgan}]]*/'',
                        data: [
                            {name:"organBianMa",value:organBianMa},
                            {name:"organName",value:organName},
                            {name:"organType",value:organType},
                            {name:"organBeiZhu",value:organBeiZhu}
                        ],
                        success: function (data) {
                            message("新增组织成功");
                        },
                        error: function(msg){
                            message(/*[[#{common.error}]]*/'');
                        }
                    }
                );
            });

            $("#delButton").click(function (event) {
                event.stopPropagation();
                var organBianMa=$("#organBianMa").val();
                $.ajax({
                        type: 'post',
                        async: false,
                        dataType : 'json',
                        url: /*[[@{delOrgan}]]*/'',
                        data: [{name:"organBianMa",value:organBianMa}],
                        success: function (data) {
                            message(/*[[#{organ.del.success}]]*/'');
                        },
                        error: function(msg){
                            message(/*[[#{common.error}]]*/'');
                        }
                    }
                );
            });
        })//ready

        // function allocateZtree() {
        //     var ids = $("#flexigrid-id").getFlexigridiAttrByIndex(0);
        //     if(ids.length !== 1){
        //         message(/*[[#{common.select.one}]]*/'');
        //         return;
        //     }

        //     $("#allocate-dialog-id").attr("organUuid",ids);
        //     // }
        //     $.ajax({
        //             type: 'post',
        //             async: false,
        //             dataType : 'json',
        //             url: /*[[@{getOrganZtreeListByOrganId}]]*/'',
        //             data: [{name:"organUuid",value:ids}],
        //             success: function (data) {
        //                 $.fn.zTree.init($("#allocate-organ-ztree"), allocateSetting, data);
        //                 $("#allocate-dialog-id").dialog('open');
        //             },
        //             error: function(msg){
        //                 message(/*[[#{common.error}]]*/'');
        //             }
        //         }
        //     );
        // }


    </script>
</head>
<body>
    <div style="flex-basis: 120px;display: flex;flex-direction: row;margin-left: 400px">
        <button th:text="解绑" style="height:30px;width:100px;"></button>
        <button th:text="绑定" style="height:30px;width:100px;"></button>
        <button id="delButton" th:text="删除" style="height:30px;width:100px;"></button>
        <button id="addButton" th:text="新增" style="height:30px;width:100px;"></button>
        <button th:text="修改" style="height:30px;width:100px;"></button>

    </div>
    <div style=": 120px;height:200px;width:500px;display: flex;flex-direction: column;margin-top: 10px;margin-left: 400px;background-color: #0066FF;">
        <div style="margin-top: 25px;margin-left: 10px;display: flex;flex-direction: row;">
            <div>
                <span><font color="white">组织编码</font></span>
                <input id="organBianMa" style="height: 30px;width: 180px">
            </div>
            <div style="margin-left: 10px">
                <span><font color="white">备注</font></span>
                <input id="organBeiZhu" style="height: 30px;width: 180px">
            </div>
        </div>
        <div style="margin-top: 25px;margin-left: 10px">
            <span><font color="white">组织名称</font></span>
            <input id="organName" style="height: 30px;width: 180px">
        </div>
        <div style="margin-top: 25px;margin-left: 10px">
            <span><font color="white">组织类型</font></span>
            <input id="organType" style="height: 30px;width: 180px">
        </div>
    </div>
    <table id="flexigrid-id"></table>
    <div id="allocate-dialog-id" style="display: none">
        <ul id="allocate-organ-ztree" class="ztree">

        </ul>
    </div>
</body>
</html>